<template>
  <nav class="navbar navbar-dark bg-primary justify-content-between mb-4" style="padding: 0px 20px;">
    <router-link class="navbar-brand" to="/">木也专栏</router-link>
    <ul v-if="!user.isLogin" class="list-inline mb-0">
      <li class="list-inline-item">
        <router-link to="/sign" class="btn btn-outline-light my-2">注册</router-link>
      </li>
      <li class="list-inline-item">
        <router-link to="/login" class="btn btn-outline-light my-2">登录</router-link>
      </li>
    </ul>
    <ul v-else class="list-inline mb-0">
      <li class="list-inline-item">
        <dropdown :title="user.nickName"></dropdown>
      </li>
    </ul>
  </nav>
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue'
import Dropdown from './Dropdown.vue'
import { UserProps } from './../store'
export default defineComponent({
  name: 'global-header',
  props: {
    user: {
      type: Object as PropType<UserProps>,
      required: true
    }
  },
  components: {
    Dropdown
  }
})
</script>
